package com.welink.cmp.convertor;

import com.welink.cmp.dao.metadata.dataobject.VpcDO;
import com.welink.cmp.domain.metadata.Vpc;

import java.util.List;
import java.util.stream.Collectors;

/**
 * VPC转换器
 */
public class VpcConvertor {

    public static VpcDO toDataObject(Vpc vpc) {
        if (vpc == null) {
            return null;
        }
        VpcDO vpcDO = new VpcDO();
        vpcDO.setId(vpc.getId());
        vpcDO.setAssetsId(vpc.getAssetsId());
        vpcDO.setName(vpc.getName());
        vpcDO.setSn(vpc.getSn());
        vpcDO.setVendor(vpc.getVendor());
        vpcDO.setBrand(vpc.getBrand());
        vpcDO.setDataCenterCode(vpc.getDataCenterCode());
        vpcDO.setExpirationTime(vpc.getExpirationTime());
        vpcDO.setLaunchedTime(vpc.getLaunchedTime());
        vpcDO.setRefId(vpc.getRefId());
        vpcDO.setRefName(vpc.getRefName());
        vpcDO.setAccountId(vpc.getAccountId());
        vpcDO.setStatus(vpc.getStatus());
        vpcDO.setCreateTime(vpc.getCreateTime());
        vpcDO.setUpdateTime(vpc.getUpdateTime());
        vpcDO.setCreateBy(vpc.getCreateBy());
        vpcDO.setUpdateBy(vpc.getUpdateBy());
        return vpcDO;
    }

    public static Vpc toDomainObject(VpcDO vpcDO) {
        if (vpcDO == null) {
            return null;
        }
        Vpc vpc = new Vpc();
        vpc.setId(vpcDO.getId());
        vpc.setAssetsId(vpcDO.getAssetsId());
        vpc.setName(vpcDO.getName());
        vpc.setSn(vpcDO.getSn());
        vpc.setVendor(vpcDO.getVendor());
        vpc.setBrand(vpcDO.getBrand());
        vpc.setDataCenterCode(vpcDO.getDataCenterCode());
        vpc.setExpirationTime(vpcDO.getExpirationTime());
        vpc.setLaunchedTime(vpcDO.getLaunchedTime());
        vpc.setRefId(vpcDO.getRefId());
        vpc.setRefName(vpcDO.getRefName());
        vpc.setAccountId(vpcDO.getAccountId());
        vpc.setStatus(vpcDO.getStatus());
        vpc.setCreateTime(vpcDO.getCreateTime());
        vpc.setUpdateTime(vpcDO.getUpdateTime());
        vpc.setCreateBy(vpcDO.getCreateBy());
        vpc.setUpdateBy(vpcDO.getUpdateBy());
        return vpc;
    }

    public static List<VpcDO> toDataObjectList(List<Vpc> vpcs) {
        return vpcs.stream()
                .map(VpcConvertor::toDataObject)
                .collect(Collectors.toList());
    }

    public static List<Vpc> toDomainObjectList(List<VpcDO> vpcDOs) {
        return vpcDOs.stream()
                .map(VpcConvertor::toDomainObject)
                .collect(Collectors.toList());
    }
}